package me.liekkas.notify.email;

import me.liekkas.notify.enums.LanguageEnum;
import me.liekkas.notify.sms.BizTypeEnum;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class MailRequest {

    private String toAddress;
    private String subject;
    private BizTypeEnum bizTypeEnum;
    private LanguageEnum languageEnum;
    private Map<String, Object> params = new HashMap<>();

    public MailRequest() {
    }

    public MailRequest(String toAddress, String subject, BizTypeEnum bizTypeEnum, LanguageEnum languageEnum, Map<String, Object> params) {
        this.toAddress = toAddress;
        this.subject = subject;
        this.bizTypeEnum = bizTypeEnum;
        this.languageEnum = languageEnum;
        this.params = params;
    }

    public static MailRequest.Builder builder() {
        return new MailRequest.Builder();
    }

    public String getToAddress() {
        return toAddress;
    }

    public void setToAddress(String toAddress) {
        this.toAddress = toAddress;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public BizTypeEnum getBizTypeEnum() {
        return bizTypeEnum;
    }

    public void setBizTypeEnum(BizTypeEnum bizTypeEnum) {
        this.bizTypeEnum = bizTypeEnum;
    }

    public LanguageEnum getLanguageEnum() {
        return languageEnum;
    }

    public void setLanguageEnum(LanguageEnum languageEnum) {
        this.languageEnum = languageEnum;
    }

    public Map<String, Object> getParams() {
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    /**
     * 构造器
     */
    public static class Builder {
        private String toAddress;
        private String subject;
        private BizTypeEnum bizTypeEnum;
        private LanguageEnum languageEnum;
        private Map<String, Object> params;

        Builder() {
        }

        public MailRequest.Builder toAddress(String toAddress) {
            this.toAddress = Objects.requireNonNull(toAddress, "toAddress must not be null");
            return this;
        }

        public MailRequest.Builder subject(String subject) {
            this.subject = Objects.requireNonNull(subject, "subject must not be null");
            return this;
        }

        public MailRequest.Builder bizTypeEnum(BizTypeEnum bizTypeEnum) {
            this.bizTypeEnum = Objects.requireNonNull(bizTypeEnum, "bizTypeEnum must not be null");
            return this;
        }

        public MailRequest.Builder languageEnum(LanguageEnum languageEnum) {
            this.languageEnum = Objects.requireNonNull(languageEnum, "languageEnum must not be null");
            return this;
        }

        public MailRequest.Builder addParam(String key, Object value) {
            this.params.put(key, value);
            return this;
        }

        public MailRequest build() {
            return new MailRequest(toAddress, subject, bizTypeEnum, languageEnum, params);
        }


    }

}
